using Microsoft.Extensions.DependencyInjection;
using Quartz;
using QuartzJobService1;
using QuartzWorkerService1;

IHost host = Host.CreateDefaultBuilder(args)
    .ConfigureServices((context, services) =>
    {
        services.Configure<QuartzOptions>(context.Configuration.GetSection("Quartz"));
        services.AddTransient<TheJob>();
        
        //required
        services.AddQuartz(q =>
        {
            q.UseMicrosoftDependencyInjectionJobFactory();
        });

        services.AddQuartzHostedService(options =>
        {
            // when shutting down we want jobs to complete gracefully
            options.WaitForJobsToComplete = true;
        });

        //services.AddHostedService<Worker>();
    })
    .UseWindowsService()
    .Build();

await host.RunAsync();
